import 'package:flutter/material.dart';

class ConstrainTest extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    Widget red  = const DecoratedBox(
          decoration: BoxDecoration(color: Colors.red));

    return Column(
      children: [
         ConstrainedBox(
          constraints: BoxConstraints(
            minHeight: 5,
            minWidth: double.infinity
          ),
          child: Container(
            height: 1.0,
            child: red,
          ),
        ),
        SizedBox(
          height: 80,
          width: 80,
          child: red,
        ),

        ConstrainedBox(
          constraints: BoxConstraints(
            minWidth: 90,
            minHeight:20 
          ),
          child: ConstrainedBox(
            constraints: BoxConstraints(
              minHeight: 60,
              minWidth: 60,
            ),
            child: red,
          ),
        ),
        ConstrainedBox(
          constraints: BoxConstraints(minWidth: 60.0, minHeight: 100.0),  //父
          child: UnconstrainedBox( //“去除”父级限制
            child: ConstrainedBox(
              constraints: BoxConstraints(minWidth: 90.0, minHeight: 20.0),//子
              child: red,
            ),
          )
        )
      ],
    );
  }

}